package day16.feifei.homework;

import java.io.*;

public class APlusB {
    public static void main(String[] args) throws IOException {
        File file = new File("D:\\file\\文档\\day16\\case\\文件结构\\a.txt");
        File file2 = new File("D:\\file\\文档\\day16\\case\\文件结构\\b.txt");
        InputStream is1 = new FileInputStream(file);
        InputStream is2 = new FileInputStream(file2);
        int number1 = 0;
        int number2 = 0;
        while (true) {
            int read = is1.read();
            if (read >= 0) {
                number1 = read - 48 + number1 * 10;
            } else break;
        }
        is1.close();

        while (true) {
            int read = is2.read();
            if (read >= 0) {
                number2 = read - 48 + number2 * 10;
            } else break;
        }
        is2.close();
        int num = number1 + number2;
        File file3 = new File("D:\\file\\文档\\day16\\case\\文件结构\\c.txt");
        OutputStream op = new FileOutputStream(file3);
        String s = String.valueOf(num);

        byte[] bytes = s.getBytes();
        op.write(bytes);

        op.close();
        System.out.println(num);

    }
}
